
#include "BfcpParticipantKey.hxx"

namespace bfcp
{
    BfcpParticipantKey::BfcpParticipantKey()
        : mConfId(0), mUserId(0)
    {
    }

    BfcpParticipantKey::BfcpParticipantKey(UInt32 confId, UInt16 userId)
        : mConfId(confId), mUserId(userId)
    {
    }

    BfcpParticipantKey::BfcpParticipantKey(const BfcpParticipantKey& rhs)
        : mConfId(rhs.mConfId), mUserId(rhs.mUserId)
    {
    }

    BfcpParticipantKey BfcpParticipantKey::operator=(const BfcpParticipantKey& rhs)
    {
        if (this != &rhs)
        {
            mConfId = rhs.mConfId;
            mUserId = rhs.mUserId;
        }

        return *this;
    }

    bool BfcpParticipantKey::operator<(const BfcpParticipantKey& rhs) const
    {
        if (mUserId != rhs.mUserId)
        {
            return mUserId < rhs.mUserId;
        }
        if (mConfId != rhs.mConfId)
        {
            return mConfId < rhs.mUserId;
        }

        return false;
    }

    EncodeStream& operator<<(EncodeStream& strm, const BfcpParticipantKey& key)
    {
        return strm << "[cid:" << key.mConfId << ", uid:" << key.mUserId << "]";
    }

}
